/*     */ package com.qmsk.business.keyword.keyWordReply.controller;
/*     */ 
/*     */ import com.qmsk.business.keyword.keyWordReply.dao.KeyWordReplyDAO;
/*     */ import com.qmsk.business.keyword.keyWordReply.service.KeyWordReplyService;
/*     */ import com.qmsk.business.sys.basic.UploadFileUtil;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.file.GlobalParams;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.util.ArrayList;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.commons.lang.StringUtils;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/keyWordReply"})
/*     */ public class KeyWordReplyController
/*     */ {
/*  34 */   private static final Logger logger = Logger.getLogger(KeyWordReplyController.class);
/*     */ 
/*     */   @Autowired
/*     */   private KeyWordReplyDAO dao;
/*     */ 
/*     */   @Autowired
/*     */   private KeyWordReplyService service;
/*     */ 
/*     */   @RequestMapping(value={"find/keyWordReplyList/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOptShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize) {
/*  44 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  46 */       Map params = new HashMap();
/*  47 */       MapUtils.addToMap(params, "status", 
/*  48 */         RequestUtils.getString(request, "status"));
/*  49 */       MapUtils.addPercentToMap(params, "title", 
/*  50 */         RequestUtils.getString(request, "title"));
/*  51 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/*  52 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  54 */       logger.error(e);
/*  55 */       ResponseUtils.setErrorMsgResponse(
/*  56 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"upload/image/{name}/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void uploadImage(HttpServletRequest request, HttpServletResponse response, @PathVariable("name") String name, @PathVariable("id") Long id)
/*     */   {
/*     */     try
/*     */     {
/*  74 */       String path = GlobalParams.getGlobalParams().getApacheRoot() + 
/*  75 */         "keyWordReply/" + id + "/";
/*  76 */       String httpPath = GlobalParams.getGlobalParams().getApacheUrl() + 
/*  77 */         "keyWordReply/" + id + "/";
/*     */ 
/*  79 */       List<String> listFileName = new ArrayList();
/*     */ 
/*  81 */       UploadFileUtil.uploadFileOfRequest(request, response, path, 
/*  82 */         listFileName, name);
/*     */ 
/*  84 */       String paths = "";
/*  85 */       if (listFileName != null) {
/*  86 */         for (String str : listFileName) {
/*  87 */           if (StringUtils.isNotEmpty(str)) {
/*  88 */             paths = httpPath + str;
/*     */           }
/*     */         }
/*     */       }
/*  92 */       if (StringUtils.isNotEmpty(paths))
/*     */       {
/*  94 */         int sResult = this.service.updateUrl("imageUrl", paths, id);
/*     */ 
/*  96 */         if (sResult > 0) {
/*  97 */           ResponseUtils.setSuccessResponse(response);
/*  98 */           return; }
/*  99 */         ResponseUtils.setErrorMsgResponse(
/* 100 */           RequestUtils.getUploadPicErrorMessage(request), 
/* 101 */           response);
/*     */ 
/* 103 */         return; }
/* 104 */       ResponseUtils.setErrorMsgResponse(
/* 105 */         RequestUtils.getUploadPicErrorMessage(request), 
/* 106 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 109 */       logger.error(e);
/* 110 */       ResponseUtils.setErrorMsgResponse(
/* 111 */         RequestUtils.getUploadPicErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"insert"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 126 */     String sGsonInData = request.getParameter("data");
/*     */     try
/*     */     {
/* 129 */       ParserDataSetJson p = ParserDataSetJson.fromString(sGsonInData);
/* 130 */       if ((p == null) || (!(p.isExistsInsertRows()))) {
/* 131 */         ResponseUtils.setErrorMsgResponse(
/* 132 */           RequestUtils.getReadJsonDataErrorMessage(request), 
/* 133 */           response);
/* 134 */         return;
/*     */       }
/*     */ 
/* 139 */       Long id = this.service.insertInfor(p);
/*     */ 
/* 150 */       if ((id != null) && (id.longValue() > 0L)) {
/* 151 */         String[] heads = { "id" };
/* 152 */         Object[] datas = { id };
/* 153 */         ResponseUtils.toGsonEbRst(heads, datas, response);
/* 154 */         return; }
/* 155 */       ResponseUtils.setErrorMsgResponse(
/* 156 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 157 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 160 */       logger.error(e);
/* 161 */       ResponseUtils.setErrorMsgResponse(
/* 162 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 163 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/* 179 */       Long[] arParams = RequestUtils.getIdLongSplit(request);
/* 180 */       int nResult = this.service.delete(arParams);
/* 181 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 182 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 183 */         response);
/*     */     } catch (Exception e) {
/* 185 */       logger.error(e);
/* 186 */       ResponseUtils.setErrorMsgResponse(
/* 187 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 188 */         response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"edit"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void edit(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 203 */     String sGsonInData = request.getParameter("data");
/*     */     try
/*     */     {
/* 206 */       ParserDataSetJson p = ParserDataSetJson.fromString(sGsonInData);
/* 207 */       if ((p == null) || (!(p.isExistsUpdateRows()))) {
/* 208 */         ResponseUtils.setErrorMsgResponse(
/* 209 */           RequestUtils.getReadJsonDataErrorMessage(request), 
/* 210 */           response);
/* 211 */         return;
/*     */       }
/*     */ 
/* 214 */       int nResult = this.service.updateInfor(p);
/*     */ 
/* 225 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 226 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/* 227 */         response);
/*     */     } catch (Exception e) {
/* 229 */       logger.error(e);
/* 230 */       ResponseUtils.setErrorMsgResponse(
/* 231 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 232 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.keyword.keyWordReply.controller.KeyWordReplyController
 * JD-Core Version:    0.5.3
 */